<?php

namespace frontend\models\region;

use Yii;


class Region extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%region}}';
    }
	/*
	* 获取省
	*/
	public function getProvince()
	{
		return $this->find()->select(['region_id','region_name'])->where(['region_type'=>1])->asarray()->all();
	} 
	/*
	* 获取市
	*/
	public function getCity($province_id)
	{
		return $this->find()->select(['region_id','region_name'])->where(['parent_id'=>$province_id])->asarray()->all();
	}
	/*
	* 获取县 
	*/
	public function getArea($city_id)
	{
		return $this->find()->select(['region_id','region_name'])->where(['parent_id'=>$city_id])->asarray()->all();
	}
}
